<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="static/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="static/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="static/css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="static/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="static/css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="static/img/favicon.ico">
    <!-- Tweaks for older IEs-->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
    <style>
        .table tr td,
        .table tr th {
            flex: 1;
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="page">
            <!-- Main Navbar-->
            <header class="header">
                <nav class="navbar">
                    <!-- Search Box-->
                    <div class="search-box">
                        <button class="dismiss"><i class="icon-close"></i></button>
                        <form id="searchForm" action="#" admin="search">
                            <input type="search" placeholder="What are you looking for..." class="form-control">
                        </form>
                    </div>
                    <div class="container-fluid">
                        <div class="navbar-holder d-flex align-items-center justify-content-between">
                            <!-- Navbar Header-->
                            <div class="navbar-header">
                                <!-- Navbar Brand -->
                                <a href="index.html" class="navbar-brand d-none d-sm-inline-block">
                                    <div class="brand-text d-none d-lg-inline-block"><span>淘书斋后台管理</span></div>
                            </div>
                            <!-- Navbar Menu -->
                            <ul class="nav-menu list-unstyled d-flex flex-md-row align-items-md-center">
                                <!-- Search-->
                                <li class="nav-item d-flex align-items-center">
                                    <a href="#"></a>
                                </li>

                                <!-- Logout    -->
                                <li class="nav-item">
                                    <li @click="logout()">
                                        <a href="#" class="nav-link logout"> <span class="d-none d-sm-inline">退出</span><i class="fa fa-sign-out"></i></a>
                                    </li>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </header>
            <div class="page-content d-flex align-items-stretch">
                <!-- Side Navbar -->
                <nav class="side-navbar">
                    <!-- Sidebar Header-->
                    <div class="sidebar-header d-flex align-items-center">
                        <div class="avatar"><img src="static/img/gao.jpg" alt="..." class="img-fluid rounded-circle"></div>
                        <div class="title">
                            <h1 class="h4">{{adminName}}</h1>
                            <p>管理员</p>
                        </div>
                    </div>
                    <!-- Sidebar Navidation Menus--><span class="heading">管理</span>
                    <ul class="list-unstyled">
                        <li>
                            <a href="index.html"> <i class="icon-home"></i>首页</a>
                        </li>
                        <li>
                            <a href="#bookDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>书本管理</a>
                            <ul id="bookDownDropdown" class="collapse list-unstyled ">
                                <li><a href="book.html">书本列表</a></li>
                                <li><a href="booktype.html">书本类型列表</a></li>
                            </ul>
                        </li>

                        <li>
                            <a href="#orderDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>订单管理</a>
                            <ul id="orderDownDropdown" class="collapse list-unstyled ">
                                <li><a href="order.html">订单列表</a></li>
                            </ul>
                        </li>

                        <li>
                            <a href="#userDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>用户管理</a>
                            <ul id="userDownDropdown" class="collapse list-unstyled ">
                                <li><a href="user.html">用户列表</a></li>

                            </ul>
                        </li>


                    </ul><span class="heading">设置</span>
                    <ul class="list-unstyled">
                        <li class="active">
                            <a href="#"> <i class="icon-flask"></i>权限管理 </a>
                        </li>
                    </ul>
                </nav>
                <div class="content-inner">
                    <!-- Page Header-->
                    <header class="page-header">
                        <div class="container-fluid">
                            <h2 class="no-margin-bottom">淘书斋</h2>
                        </div>
                    </header>
                    <!-- Breadcrumb-->
                    <div class="breadcrumb-holder container-fluid">
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html">首页</a></li>
                            <li class="breadcrumb-item active">权限管理 </li>
                        </ul>
                    </div>



                    <section class="tables">
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="card" id="cardhtml">
                                        <div class="card-close">
                                            <div class="dropdown">
                                                <button type="button" id="closeCard1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle"><i class="fa fa-ellipsis-v"></i></button>
                                                <div aria-labelledby="closeCard1" class="dropdown-menu dropdown-menu-right has-shadow">
                                                    <a class="dropdown-item edit" @click="addModal()"> <i class="glyphicon glyphicon-plus"></i>添加管理员</a>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="card-header d-flex align-items-center">
                                            <h3 class="h4">管理员列表</h3>
                                        </div>


                                        <!-- <div class="card-body">
                                            <form class="form-inline">
                                                <div class="col-md-3"></div>
                                                &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
                                                <div class="form-group">
                                                    <select name="account" class="form-control" @change="selectChange($event)">
                                                        <option value="" selected="disabled" style="display:none">选择权限类型</option>
                                                        <option v-for="(item,index) in roleList" :value="item.bookTypeId">{{item.typeName}}</option>
                                                            </select>
                                                </div>
                                                &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
                                                <div class="form-group">
                                                    <label for="inlineFormInputGroup" class="sr-only">Username</label>
                                                    <input v-model="bookId" id="inlineFormInputGroup" type="text" placeholder="按编号搜索" class="mr-3 form-control">
                                                </div>
                                                <div class="form-group">
                                                    <button class="btn btn-primary" type="button" @click="findById()">搜索</button>
                                                </div>
                                                &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
                                                <div class="form-group">
                                                    <label for="inlineFormInputGroup" class="sr-only">Username</label>
                                                    <input v-model="bookName" id="inlineFormInputGroup" type="text" placeholder="按名字搜索" class="mr-3 form-control">
                                                </div>
                                                <div class="form-group">
                                                    <button class="btn btn-primary" type="button" @click="findByName()">搜索</button>
                                                </div>
                                            </form>
                                        </div> -->

                                        <div class="card-body">

                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                                    <thead>
                                                        <tr>
                                                            <th>编号</th>
                                                            <th>用户名</th>
                                                            <th>权限</th>
                                                            <th>操作</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <tr v-for="(item,index) in adminList">
                                                            <template v-if="item.adminRole.length>1">
                                                            <th scope="row">{{item.adminId}}</th>
                                                            <td>{{item.username}}</td>
                                                            <td>超级管理员</td>
                                                            <td>
                                                                <!-- Standard button -->
                                                                <button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#editModal" @click="editHyper(item)"><span class="icon-search" aria-hidden="true"></span> 更新用户</button>
                                                                <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#passwordModal" @click="editPwd(item)"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>重置密码</button>
                                                            </td>
                                                        </template>

                                                            <template v-else>
                                                                <th scope="row">{{item.adminId}}</th>
                                                                <td>{{item.username}}</td>
                                                                <td>{{item.adminRole[0].role.nameZh}}</td>
                                                                <td>
                                                                    <!-- Standard button -->
                                                                    <button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#editModal" @click="edit(item)"><span class="icon-search" aria-hidden="true"></span> 更新用户</button>
                                                                    <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#passwordModal" @click="editPwd(item)"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>重置密码</button>
                                                                    <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#deleteModal" @click="deleteModal(item.adminId,item.username)"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> 删除</button>
                                                                </td>
                                                            </template>

                                                        </tr>



                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>


                                        <form class="form-inline">
                                            <div class="col-md-7"></div>
                                            <div id="page_nav">
                                                <nav aria-label="Page navigation">
                                                    <ul class="pagination">
                                                        <li @click="firstPage()"><a>首页</a></li>

                                                        <li v-if="ifHasPrevious" @click="prePage()">
                                                            <a aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
                                                            </a>
                                                        </li>

                                                        <li v-else class="disabled">
                                                            <a aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
                                                            </a>
                                                        </li>
                                                        <template v-for="(item,index) in pageNums">
                                                        <li v-if="item==currentPage" class="active" @click="numPage(item, $event)"><a>{{item}}</a></li>
                                                        <li v-else @click="numPage(item, $event)"><a>{{item}}</a></li>
                                                    </template>
                                                        <li v-if="ifHasNext" @click="nextPage()">
                                                            <a aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                                            </a>
                                                        </li>

                                                        <li v-else class="disabled">
                                                            <a aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                                            </a>
                                                        </li>
                                                        <li @click="lastPage()"><a>尾页</a></li>
                                                    </ul>
                                                </nav>
                                            </div>
                                        </form>



                                    </div>


                                </div>


                            </div>
                    </section>


                    <!-- Modal-->
                    <div id="deleteModal" tabindex="-1" admin="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
                        <div admin="document" class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 id="exampleModalLabel" class="modal-title">确认删除该管理员？</h4>
                                    <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                                </div>
                                <div class="modal-body">

                                    <p>编号：{{deleteModalId}}</p>
                                    <p>用户名：{{deleteModalName}}</p>


                                </div>
                                <div class="modal-footer">
                                    <button type="button" data-dismiss="modal" class="btn btn-secondary">取消</button>
                                    <button type="button" class="btn btn-primary" @click="deleteAdmin()">确认</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Modal-->
                    <div id="editModal" tabindex="-1" admin="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
                        <div admin="document" class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 id="exampleModalLabel" class="modal-title">更新用户</h4>
                                    <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                                </div>
                                <div class="modal-body">
                                    <form>
                                        <div v-if="userNameVaild==='0'" class="form-group row">
                                            &nbsp;&nbsp;<label class="form-control-label">用户名</label>
                                            <div class="col-sm-6">
                                                <input v-model="admin.username" type="text" placeholder="请输入名称" class="form-control" @change="editNameChange()">
                                            </div>
                                        </div>

                                        <div v-else-if="userNameVaild==='1'" class="form-group row has-success">

                                            &nbsp;&nbsp;<label class="form-control-label">用户名</label>
                                            <div class="col-sm-6">
                                                <input v-model="admin.username" type="text" placeholder="请输入名称" class="form-control is-valid" @change="editNameChange()">
                                            </div>
                                        </div>

                                        <div v-else class="form-group row has-danger">

                                            &nbsp;&nbsp;<label class="form-control-label">用户名</label>
                                            <div class="col-sm-6">
                                                <input v-model="admin.username" type="text" placeholder="请输入名称" class="form-control is-invalid" @change="editNameChange()">
                                                <div class="invalid-feedback">用户名可含有英文、数字,长度为2到12位</div>
                                            </div>
                                        </div>

                                        <div v-if="roleIdSelected!=4" class="form-group row ">
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">权限</label>
                                            <div class="col-sm-6">
                                                <select v-model="roleIdSelected" @change="selectRoleChange($event)" name="account " class="form-control mb-3">
                                                
                      <option v-for="(item,index) in addRoleList" :value="item.id">{{item.name}}</option>
                    </select>
                                            </div>
                                        </div>

                                    </form>

                                </div>
                                <div class="modal-footer">
                                    <button type="button" data-dismiss="modal" class="btn btn-secondary">取消</button>
                                    <button type="button" class="btn btn-primary" @click="updateAdmin()">确认</button>
                                </div>
                            </div>



                        </div>
                    </div>

                    <!-- Modal-->
                    <div id="passwordModal" tabindex="-1" admin="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
                        <div admin="document" class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 id="exampleModalLabel" class="modal-title">重置密码</h4>
                                    <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                                </div>
                                <div class="modal-body">
                                    <form>
                                        <div v-if="passwordValid==='0'" class="form-group row">
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">密码</label>&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="admin.password" type="password" placeholder="请输入密码" class="form-control" @change="editPasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else-if="passwordValid==='1'" class="form-group row has-success">

                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">密码</label>&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="admin.password" type="password" placeholder="请输入密码" class="form-control is-valid" @change="editPasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else class="form-group row has-danger">

                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">密码</label>&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="admin.password" type="password" placeholder="请输入密码" class="form-control is-invalid" @change="editPasswordChange()">
                                                <div class="invalid-feedback">必须包含一个大写，一个小写字母，一个数字，长度为6到16位</div>
                                            </div>
                                        </div>
                                        <div v-if="confirmPasswordValid==='0'" class="form-group row">
                                            &nbsp;&nbsp;<label class="form-control-label">确认密码</label>
                                            <div class="col-sm-6">
                                                <input v-model="confirmPassword" type="password" placeholder="请输入密码" class="form-control" @change="confirmPasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else-if="confirmPasswordValid==='1'" class="form-group row has-success">

                                            &nbsp;&nbsp;<label class="form-control-label">确认密码</label>
                                            <div class="col-sm-6">
                                                <input v-model="confirmPassword" type="password" placeholder="请输入密码" class="form-control is-valid" @change="confirmPasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else class="form-group row has-danger">

                                            &nbsp;&nbsp;<label class="form-control-label">确认密码</label>
                                            <div class="col-sm-6">
                                                <input v-model="confirmPassword" type="password" placeholder="请输入密码" class="form-control is-invalid" @change="confirmPasswordChange()">
                                                <div class="invalid-feedback">前后密码不一致</div>
                                            </div>
                                        </div>


                                    </form>

                                </div>
                                <div class="modal-footer">
                                    <button type="button" data-dismiss="modal" class="btn btn-secondary">取消</button>
                                    <button type="button" class="btn btn-primary" @click="updateAdminPwd()">确认</button>
                                </div>
                            </div>



                        </div>
                    </div>

                    <!-- Modal-->
                    <div id="addModal" tabindex="-1" admin="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
                        <div admin="document" class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 id="exampleModalLabel" class="modal-title">添加管理员</h4>
                                    <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                                </div>
                                <div class="modal-body">
                                    <form>
                                        <div v-if="userNameVaild==='0'" class="form-group row">
                                            &nbsp;&nbsp;<label class="form-control-label">用户名</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="addadmin.username" type="text" placeholder="用户名" class="form-control" @change="addNameChange()">
                                            </div>
                                        </div>

                                        <div v-else-if="userNameVaild==='1'" class="form-group row has-success">

                                            &nbsp;&nbsp;<label class="form-control-label">用户名</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="addadmin.username" type="text" placeholder="用户名" class="form-control is-valid" @change="addNameChange()">
                                            </div>
                                        </div>

                                        <div v-else class="form-group row has-danger">

                                            &nbsp;&nbsp;<label class="form-control-label">用户名</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="addadmin.username" type="text" placeholder="用户名" class="form-control is-invalid" @change="addNameChange()">
                                                <div class="invalid-feedback">用户名可含有英文、数字,长度为2到12位</div>
                                            </div>
                                        </div>

                                        <div v-if="passwordValid==='0'" class="form-group row">
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">密码</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="addadmin.password" type="password" placeholder="请输入密码" class="form-control" @change="addpasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else-if="passwordValid==='1'" class="form-group row has-success">

                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">密码</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="addadmin.password" type="password" placeholder="请输入密码" class="form-control is-valid" @change="addpasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else class="form-group row has-danger">

                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">密码</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="addadmin.password" type="password" placeholder="请输入密码" class="form-control is-invalid" @change="addpasswordChange()">
                                                <div class="invalid-feedback">必须包含一个大写，一个小写字母，一个数字，长度为6到16位</div>
                                            </div>
                                        </div>

                                        <div v-if="confirmPasswordValid==='0'" class="form-group row">
                                            &nbsp;&nbsp;<label class="form-control-label">确认密码</label>&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="confirmPassword" type="password" placeholder="请输入密码" class="form-control" @change="confirmAddPasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else-if="confirmPasswordValid==='1'" class="form-group row has-success">

                                            &nbsp;&nbsp;<label class="form-control-label">确认密码</label>&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="confirmPassword" type="password" placeholder="请输入密码" class="form-control is-valid" @change="confirmAddPasswordChange()">
                                            </div>
                                        </div>

                                        <div v-else class="form-group row has-danger">

                                            &nbsp;&nbsp;<label class="form-control-label">确认密码</label>&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <input v-model="confirmPassword" type="password" placeholder="请输入密码" class="form-control is-invalid" @change="confirmAddPasswordChange()">
                                                <div class="invalid-feedback">前后密码不一致</div>
                                            </div>
                                        </div>

                                        <div v-if="roleIdSelected!=4" class="form-group row ">
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="form-control-label">权限</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="col-sm-6">
                                                <select v-model="roleIdSelected" @change="selectRoleChange($event)" name="account " class="form-control mb-3">
                                                
                      <option v-for="(item,index) in addRoleList" :value="item.id">
                         
                        {{item.name}}
                 
                        </option>
                    </select>
                                            </div>

                                        </div>

                                    </form>

                                </div>
                                <div class="modal-footer">
                                    <button type="button" data-dismiss="modal" class="btn btn-secondary">取消</button>
                                    <button type="button" class="btn btn-primary" @click="addAdminSubmit()">确认</button>
                                </div>
                            </div>
                        </div>
                    </div>




                    <!-- Page Footer-->
                    <footer class="main-footer">
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-6">
                                    <p class="weui-footer__text">Copyright © 2019 <a style="color:#3f8b81" href="#">抓娃小组</a>&nbsp版权所有</p>
                                </div>
                                <div class="col-sm-6 text-right">
                                    <p></p>
                                    <!-- Please do not remove the backlink to us unless you support further theme's development at https://bootstrapious.com/donate. It is part of the license conditions. Thank you for understanding :)-->
                                </div>
                            </div>
                        </div>
                    </footer>
                    </div>
                </div>
            </div>

        </div>






        <!-- JavaScript files-->
        <script src="static/vendor/jquery/jquery.min.js"></script>
        <script src="static/vendor/popper.js/umd/popper.min.js">
        </script>
        <script src="static/vendor/bootstrap/js/bootstrap.min.js"></script>
        <script src="static/vendor/jquery.cookie/jquery.cookie.js">
        </script>
        <script src="static/vendor/chart.js/Chart.min.js"></script>
        <script src="static/vendor/jquery-validation/jquery.validate.min.js"></script>
        <script src="static/js/charts-home.js"></script>
        <!-- Main File-->
        <script src="static/js/front.js"></script>
        <script src="static/node_modules/vue/dist/vue.js"></script>

        <script>
            var vm = new Vue({
                el: '#app',
                data: {
                    adminName: '',
                    pageNums: [],
                    currentPage: 0,
                    pageCount: 0,
                    ifHasPrevious: false,
                    ifHasNext: true,
                    msg: 'hello',
                    adminList: [],
                    //服务器:http://47.100.136.219
                    serverIp: 'http://47.100.136.219',
                    ifLocal: false,
                    roleId: 0,
                    adminRoleId: 0,
                    roleList: [],
                    deleteModalId: '',
                    deleteModalName: '',
                    userNameVaild: '0',
                    passwordValid: '0',
                    confirmPasswordValid: '0',
                    roleIdSelected: 1,
                    admin: {
                        adminId: 0,
                        username: '',
                        password: '',
                    },
                    adminIndex: 0,
                    addadmin: {

                        username: '',
                        password: '',
                    },
                    confirmPassword: '',
                    roleList: [{
                        'id': '0',
                        'name': '全部',
                    }, {
                        'id': '1',
                        'name': '图书管理员',
                    }, {
                        'id': '2',
                        'name': '订单管理员',
                    }, {
                        'id': '3',
                        'name': '用户管理员',
                    }, {
                        'id': '4',
                        'name': '超级管理员',
                    }],
                    addRoleList: [{
                        'id': '1',
                        'name': '图书管理员',
                    }, {
                        'id': '2',
                        'name': '订单管理员',
                    }, {
                        'id': '3',
                        'name': '用户管理员',
                    }],

                },
                mounted() {

                    if (this.ifLocal) {
                        this.serverIp = "http://localhost";
                    }

                    let _this = this;

                    $.ajax({
                        type: "GET",
                        url: _this.serverIp + ":8088/boot/admincommon/info",
                        success: function(response) {
                            if (response.code == 200) {
                                console.log(response.data);
                                _this.adminName = response.data.data.principal.username
                            }
                        },

                    });

                    this.currentPage = 1;

                    this.createAdminList();



                },
                methods: {

                    logout() {
                        let _this = this;
                        $.ajax({
                            url: _this.serverIp + ':8088/boot/logout',
                            type: 'POST',
                            success: function(res, status) {
                                console.log(res);
                                location.href = "login.html";

                            },
                            error: function(res, status) {
                                console.log(res);
                            }
                        });
                    },

                    createAdminList() {
                        let _this = this;
                        $.ajax({
                            type: "GET",
                            url: _this.serverIp + ":8088/boot/adminhyper/role/?pageIndex=" + _this.currentPage + "&role_id=" + _this.roleId,
                            success: function(response) {
                                if (response.code == 200) {
                                    console.log(response.data);
                                    console.log(response.data.role.list);
                                    _this.adminList = response.data.role.list;
                                    _this.pageNums = response.data.role.navigatepageNums;
                                    _this.pageCount = response.data.role.pages;
                                }
                            },
                            error: function(response) {

                                $("#cardhtml").replaceWith('<div class="card-close"></div><div class="card-header d-flex align-items-center"><h3 class="h4">不好意思，您不是超级管理员，无权访问</h3></div>');


                            }
                        });
                    },

                    addModal() {
                        this.passwordValid = '0';
                        this.confirmPasswordValid = '0';
                        this.userNameVaild = '0';
                        this.roleIdSelected = 1;
                        this.addadmin = {

                            username: '',
                            password: '',
                        };
                        $("#addModal").modal("show");
                    },

                    editPwd(item) {
                        this.passwordValid = '0';
                        this.confirmPasswordValid = '0';
                        this.admin.password = '';
                        this.admin.adminId = item.adminId;
                    },


                    addAdminSubmit() {
                        let _this = this;

                        if (_this.userNameVaild != "1" && _this.passwordValid != "1" && _this.confirmPasswordValid != "1") {
                            alert("请填写正确信息再保存!");
                            return;
                        }

                        console.log(_this.addadmin);
                        console.log(_this.roleIdSelected);

                        console.log("开始提交数据");
                        $.ajax({
                            type: "POST",
                            url: _this.serverIp + ":8088/boot/adminhyper/role",
                            data: {
                                username: _this.addadmin.username,
                                password: _this.admin.password,
                                roleId: _this.roleIdSelected
                            }, //必要

                            success: function(response) {
                                if (response.code == 200) {
                                    console.log(response.data);
                                    $('#addModal').modal('hide');
                                    _this.userNameVaild = '0';
                                    _this.passwordValid = '0';
                                    _this.confirmPasswordValid = '0';
                                    _this.confirmPassword = '';
                                    _this.createAdminList();

                                } else {
                                    alert("已存在该用户名，请换一个哦");
                                }
                            }
                        });
                    },

                    updateAdmin() {
                        let _this = this;

                        if (_this.userNameVaild == "-1") {
                            alert("请填写正确信息再保存!");
                            return;
                        }

                        console.log(_this.admin);
                        console.log(_this.roleIdSelected);

                        console.log("开始提交数据");
                        $.ajax({
                            type: "PUT",
                            url: _this.serverIp + ":8088/boot/adminhyper/role",
                            data: {
                                username: _this.admin.username,
                                adminId: _this.admin.adminId,
                                roleId: _this.roleIdSelected
                            }, //必要

                            success: function(response) {
                                if (response.code == 200) {
                                    console.log(response.data);
                                    $('#editModal').modal('hide');
                                    _this.userNameVaild = '0';

                                    _this.createAdminList();

                                }
                            }
                        });
                    },
                    updateAdminPwd() {
                        let _this = this;

                        if (_this.passwordValid != "1" && _this.confirmPasswordValid != "1") {
                            alert("请填写正确信息再保存!");
                            return;
                        }

                        console.log(_this.admin);

                        console.log("开始提交数据");
                        $.ajax({
                            type: "PUT",
                            url: _this.serverIp + ":8088/boot/adminhyper/updatepwd",
                            data: {
                                password: _this.admin.password,
                                adminId: _this.admin.adminId,
                            }, //必要

                            success: function(response) {
                                if (response.code == 200) {
                                    console.log(response.data);
                                    $('#passwordModal').modal('hide');
                                    _this.passwordValid = '0';
                                    _this.confirmPasswordValid = '0';
                                    _this.confirmPassword = '';
                                    _this.createAdminList();

                                }
                            }
                        });
                    },



                    edit(item) {
                        this.userNameVaild = '0';
                        this.admin.adminId = item.adminId;
                        this.admin.username = item.username
                        this.roleIdSelected = item.adminRole[0].roleId;
                        console.log(this.roleIdSelected);
                    },

                    editHyper(item) {
                        this.userNameVaild = '0';
                        this.admin.adminId = item.adminId;
                        this.admin.username = item.username
                        if (item.adminRole.length > 1)
                            this.roleIdSelected = 4;
                        console.log(this.roleIdSelected);
                    },


                    deleteModal(id, name) {

                        this.deleteModalId = id;
                        this.deleteModalName = name;
                    },

                    deleteAdmin() {
                        console.log(this.deleteModalId);

                        let _this = this;
                        $.ajax({
                            type: "DELETE",
                            url: _this.serverIp + ":8088/boot/adminhyper/role/" + _this.deleteModalId,
                            success: function(response) {
                                if (response.code == 200) {
                                    console.log(response.data);
                                    $('#deleteModal').modal('hide');
                                    _this.createAdminList();

                                }
                            },
                        });

                    },
                    selectChange(e) {
                        console.log(e.target.value) // 选择项的value
                        this.currentPage = 1;
                        this.bookTypeId = e.target.value;
                        this.condition = '';
                        let _this = this;
                        this.createBookList();
                    },
                    selectRoleChange(e) {
                        this.roleIdSelected = e.target.value;
                    },

                    findById() {
                        console.log(this.condition);
                        this.currentPage = 1;
                        this.bookName = '';
                        this.bookTypeId = 0;
                        let _this = this;
                        this.createBookListById();
                    },
                    findByName() {
                        console.log(this.condition);
                        this.currentPage = 1;
                        this.bookId = '';
                        this.bookTypeId = 0;
                        let _this = this;
                        this.createBookListByName();
                    },

                    prePage() {

                        this.currentPage = this.currentPage - 1;

                        this.createBookList();
                    },
                    nextPage() {
                        this.currentPage = this.currentPage + 1;
                        this.createBookList();
                    },

                    firstPage() {

                        this.currentPage = 1;
                        this.createBookList();
                    },
                    lastPage() {

                        this.currentPage = this.pageCount;
                        this.createBookList();

                    },


                    numPage: function(num, event) {
                        if (this.curpage == num) {
                            return;
                        }

                        this.currentPage = num;
                        this.createBookList();

                    },


                    addNameChange() {
                        let _this = this;
                        var name = /(^[A-Za-z0-9]{2,12}$)/;
                        if (!name.test(_this.addadmin.username)) {
                            _this.userNameVaild = "-1";
                        } else {
                            _this.userNameVaild = "1";
                        }
                    },
                    addpasswordChange() {
                        let _this = this;
                        var password = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{6,16}$/;

                        if (!password.test(_this.addadmin.password)) {
                            _this.passwordValid = "-1";
                        } else {
                            _this.passwordValid = "1";
                        }
                    },

                    editNameChange() {
                        let _this = this;
                        var name = /(^[A-Za-z0-9]{2,12}$)/;
                        if (!name.test(_this.admin.username)) {
                            _this.userNameVaild = "-1";
                        } else {
                            _this.userNameVaild = "1";
                        }
                    },
                    editPasswordChange() {
                        let _this = this;
                        var password = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{6,16}$/;
                        if (!password.test(_this.admin.password)) {
                            _this.passwordValid = "-1";
                        } else {
                            _this.passwordValid = "1";
                        }
                    },
                    confirmPasswordChange() {

                        let _this = this;

                        if (_this.admin.password != _this.confirmPassword) {
                            _this.confirmPasswordValid = "-1";
                        } else {
                            _this.confirmPasswordValid = "1";
                        }
                    },
                    confirmAddPasswordChange() {

                        let _this = this;

                        if (_this.addadmin.password != _this.confirmPassword) {
                            _this.confirmPasswordValid = "-1";
                        } else {
                            _this.confirmPasswordValid = "1";
                        }
                    }


                },
            });
        </script>
        </script>
</body>

</html